package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.StatisticsContentStats;
import com.ruoyi.system.service.IStatisticsContentStatsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 存放每篇内容的统计数据Controller
 * 
 * @author ruoyi
 * @date 2024-08-15
 */
@RestController
@RequestMapping("/system/content")
public class StatisticsContentStatsController extends BaseController
{
    @Autowired
    private IStatisticsContentStatsService statisticsContentStatsService;

    /**
     * 查询存放每篇内容的统计数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:content:list')")
    @GetMapping("/list")
    public TableDataInfo list(StatisticsContentStats statisticsContentStats)
    {
        startPage();
        List<StatisticsContentStats> list = statisticsContentStatsService.selectStatisticsContentStatsList(statisticsContentStats);
        return getDataTable(list);
    }

    /**
     * 导出存放每篇内容的统计数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:content:export')")
    @Log(title = "存放每篇内容的统计数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StatisticsContentStats statisticsContentStats)
    {
        List<StatisticsContentStats> list = statisticsContentStatsService.selectStatisticsContentStatsList(statisticsContentStats);
        ExcelUtil<StatisticsContentStats> util = new ExcelUtil<StatisticsContentStats>(StatisticsContentStats.class);
        util.exportExcel(response, list, "存放每篇内容的统计数据数据");
    }

    /**
     * 获取存放每篇内容的统计数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:content:query')")
    @GetMapping(value = "/{statId}")
    public AjaxResult getInfo(@PathVariable("statId") Long statId)
    {
        return success(statisticsContentStatsService.selectStatisticsContentStatsByStatId(statId));
    }

    /**
     * 新增存放每篇内容的统计数据
     */
    @PreAuthorize("@ss.hasPermi('system:content:add')")
    @Log(title = "存放每篇内容的统计数据", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StatisticsContentStats statisticsContentStats)
    {
        return toAjax(statisticsContentStatsService.insertStatisticsContentStats(statisticsContentStats));
    }

    /**
     * 修改存放每篇内容的统计数据
     */
    @PreAuthorize("@ss.hasPermi('system:content:edit')")
    @Log(title = "存放每篇内容的统计数据", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StatisticsContentStats statisticsContentStats)
    {
        return toAjax(statisticsContentStatsService.updateStatisticsContentStats(statisticsContentStats));
    }

    /**
     * 删除存放每篇内容的统计数据
     */
    @PreAuthorize("@ss.hasPermi('system:content:remove')")
    @Log(title = "存放每篇内容的统计数据", businessType = BusinessType.DELETE)
	@DeleteMapping("/{statIds}")
    public AjaxResult remove(@PathVariable Long[] statIds)
    {
        return toAjax(statisticsContentStatsService.deleteStatisticsContentStatsByStatIds(statIds));
    }
}
